package com.ezreal.ezchat.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class LocalAccountBean implements Serializable {

    public static final String MSG_PWD_KEY = "msg_pwd_key";
    public static final String LOCATION_KEY = "location_key";
    public static final String READ_DESTROY_KEY = "read_destroy_key";

    private Map<String, String> extendMap = new HashMap<>();

    private String mHeadImgUrl;
    private String mAccount;
    private String mNick;
    private GenderEnum mGenderEnum;
    private String mBirthDay;
    private String mLocation;
    private String mSignature;
    private String msgPwd;
    private boolean openReadDestroy;

    public String getHeadImgUrl() {
        return mHeadImgUrl;
    }

    public void setHeadImgUrl(String headImgUrl) {
        mHeadImgUrl = headImgUrl;
    }

    public String getAccount() {
        return mAccount;
    }

    public void setAccount(String account) {
        mAccount = account;
    }

    public String getNick() {
        return mNick;
    }

    public void setNick(String nick) {
        mNick = nick;
    }

    public GenderEnum getGenderEnum() {
        return mGenderEnum;
    }

    public void setGenderEnum(GenderEnum genderEnum) {
        mGenderEnum = genderEnum;
    }

    public String getBirthDay() {
        return mBirthDay;
    }

    public void setBirthDay(String birthDay) {
        mBirthDay = birthDay;
    }

    public String getLocation() {
        return mLocation;
    }

    public void setLocation(String mLocation) {
        this.mLocation = mLocation;
        this.extendMap.put(LOCATION_KEY, mLocation);
    }

    public String getSignature() {
        return mSignature;
    }

    public void setSignature(String signature) {
        mSignature = signature;
    }

    public String getMsgPwd() {
        return msgPwd;
    }

    public void setMsgPwd(String msgPwd) {
        this.msgPwd = msgPwd;
        this.extendMap.put(MSG_PWD_KEY, msgPwd);
    }

    public boolean getOpenReadDestroy() {
        return openReadDestroy;
    }

    public void setOpenReadDestroy(boolean openReadDestroy) {
        this.openReadDestroy = openReadDestroy;
        this.extendMap.put(READ_DESTROY_KEY, String.valueOf(openReadDestroy));
    }

    public void setExtendInfo(String extendInfo) {
        Type type = new TypeToken<HashMap<String, String>>() {
        }.getType();
        Map<String, String> extendMap = new Gson().fromJson(extendInfo, type);
        this.mLocation = extendMap.get(LOCATION_KEY);
        this.msgPwd = extendMap.get(MSG_PWD_KEY);
        this.openReadDestroy = Boolean.parseBoolean(extendMap.get(READ_DESTROY_KEY));
    }

    public String getExtendInfo() {
        return new Gson().toJson(extendMap);
    }
}
